﻿
Imports DevComponents.DotNetBar

Public Enum enumCategories
    Company
    ForeignCompany
    ContainerType
    Country
    DemDet
    Driver
    Good
    Config
    Currency
    Agent
    Fee
    Unit
    Accessory
    Vessel
    Line
    Port
    Truck
    ContOfTNC
    AccessoryOfCont
End Enum

Public Class ucCategories
    Private currCategory As enumCategories
    Private currentButtonItem As ButtonItem

    Public Sub New(ByVal enumCat As enumCategories)
        InitializeComponent()
        currCategory = enumCat
    End Sub

    Private Sub ucCategories_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Me.Load
        currentButtonItem = itemPanelFile.Items(0)
        Select Case currCategory
            Case enumCategories.Company
                ButtonItemCompany.Checked = True
                ButtonItemCompany_Click(Nothing, Nothing)
            Case enumCategories.ForeignCompany
                ButtonItemForeignCompany.Checked = True
                ButtonItemForeignCompany_Click(Nothing, Nothing)
            Case enumCategories.ContainerType
                ButtonItemContType.Checked = True
                ButtonItemContType_Click(Nothing, Nothing)
            Case enumCategories.DemDet
                ButtonItemWarehouse.Checked = True
                ButtonItemWarehouse_Click(Nothing, Nothing)
            Case enumCategories.Driver
                ButtonItemDriver.Checked = True
                buttonItemDriver_Click(Nothing, Nothing)
            Case enumCategories.Truck
                ButtonItemTruck.Checked = True
                buttonItemTruck_Click(Nothing, Nothing)
            Case enumCategories.Config
                ButtonItemConfig.Checked = True
                ButtonItemConfig_Click(Nothing, Nothing)
            Case enumCategories.Good
                ButtonItemGoodType.Checked = True
                ButtonItemGoodType_Click(Nothing, Nothing)
            Case enumCategories.Agent
                ButtonItemAgent.Checked = True
                buttonItemAgent_Click(Nothing, Nothing)
            Case enumCategories.Fee
                ButtonItemCharge.Checked = True
                ButtonItemCharge_Click(Nothing, Nothing)
            Case enumCategories.Unit
                ButtonItemUnit.Checked = True
                ButtonItemUnit_Click(Nothing, Nothing)
            Case enumCategories.Accessory
                ButtonItemAccessory.Checked = True
                ButtonItemAccessory_Click(Nothing, Nothing)
            Case enumCategories.Vessel
                ButtonItemVessel.Checked = True
                ButtonItemVessel_Click(Nothing, Nothing)
            Case enumCategories.Line
                ButtonItemLine.Checked = True
                ButtonItemLine_Click(Nothing, Nothing)
            Case enumCategories.Currency
                ButtonItemCurrency.Checked = True
                ButtonItemCurrency_Click(Nothing, Nothing)
            Case enumCategories.Port
                ButtonItemPort.Checked = True
                ButtonItemPort_Click(Nothing, Nothing)
            Case enumCategories.Country
                ButtonItemCountry.Checked = True
                ButtonItemCountry_Click(Nothing, Nothing)
            Case enumCategories.Driver
                ButtonItemDriver.Checked = True
                buttonItemDriver_Click(Nothing, Nothing)
            Case enumCategories.Truck
                ButtonItemTruck.Checked = True
                buttonItemTruck_Click(Nothing, Nothing)
            Case enumCategories.ContOfTNC
                btnContOfTNC.Checked = True
                btnContOfTNC_Click(Nothing, Nothing)
            Case enumCategories.AccessoryOfCont
                btnAccessoryOfCont.Checked = True
                btnAccessoryOfCont_Click(Nothing, Nothing)
        End Select
    End Sub

    Private Sub LoadUserControl(ByVal uc As System.Windows.Forms.UserControl)
        'Clear các form đã load
        PanelExUserControl.Controls.Clear()
        'Load form mới
        PanelExUserControl.Controls.Add(uc)
        uc.Dock = DockStyle.Fill
    End Sub

    ''' <summary>
    ''' Load user control
    ''' </summary>
    ''' <param name="uc">uc hiện hành</param>
    ''' <param name="ucInit">uc khởi tạo mới</param>
    ''' <remarks></remarks>
    Private Sub ButtonItem_Click(ByRef uc As UserControl, ByVal ucInit As UserControl)
        'Kiểm tra nếu chưa load usercontrol này thì load lên
        If Not PanelExUserControl.Controls.Contains(uc) Then
            'Set image
            currentButtonItem.Image = Global.TNCVB.My.Resources.Resources.folder_24
            Dim item As ButtonItem = itemPanelFile.SelectedItems(0)
            item.Image = Global.TNCVB.My.Resources.Resources.folder_vectors_24
            'Update current ButtonItem
            currentButtonItem = item
            currentButtonItem.Checked = True
            'Nếu uc chưa có thì gán = ucInit mới
            If uc Is Nothing Then
                uc = ucInit
            End If
            LoadUserControl(uc)
        End If
    End Sub

    Private _ucDemDet As New ucDemDet
    Private Sub ButtonItemWarehouse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonItemWarehouse.Click
        ButtonItem_Click(_ucDemDet, New ucDemDet)
    End Sub

    Private _ucContType As ucContType
    Private Sub ButtonItemContType_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonItemContType.Click
        ''Kiểm tra nếu chưa load usercontrol này thì load lên
        'If Not PanelExUserControl.Controls.Contains(_ucContType) Then
        '    'Set image
        '    currentButtonItem.Image = Global.TNCVB.My.Resources.Resources.folder_24
        '    Me.buttonItemContType.Image = Global.TNCVB.My.Resources.Resources.folder_vectors_24
        '    'Update current ButtonItem
        '    currentButtonItem = Me.buttonItemContType

        '    If _ucContType Is Nothing Then
        '        _ucContType = New ucContType()
        '    End If
        '    LoadUserControl(_ucContType)
        'End If
        ButtonItem_Click(_ucContType, New ucContType)
    End Sub

    Private _ucCompany As ucCompany
    Private Sub ButtonItemCompany_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonItemCompany.Click
        ''Kiểm tra nếu chưa load usercontrol này thì load lên
        'If Not PanelExUserControl.Controls.Contains(_ucCompany) Then
        '    'Set image
        '    currentButtonItem.Image = Global.TNCVB.My.Resources.Resources.folder_24
        '    Me.ButtonItemCompany.Image = Global.TNCVB.My.Resources.Resources.folder_vectors_24
        '    'Update current ButtonItem
        '    currentButtonItem = ButtonItemCompany

        '    If _ucCompany Is Nothing Then
        '        _ucCompany = New ucCompany()
        '    End If
        '    LoadUserControl(_ucCompany)
        'End If

        ButtonItem_Click(_ucCompany, New ucCompany)
    End Sub

    Private _ucForeignCompany As New ucForeignCompany
    Private Sub ButtonItemForeignCompany_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonItemForeignCompany.Click
        ButtonItem_Click(_ucForeignCompany, New ucForeignCompany)
    End Sub

    Private _ucConfig As New ucConfig
    Private Sub ButtonItemConfig_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonItemConfig.Click
        ButtonItem_Click(_ucConfig, New ucConfig)
    End Sub

    Private _ucDriver As New ucDriver
    Private Sub buttonItemDriver_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonItemDriver.Click
        ButtonItem_Click(_ucDriver, New ucDriver)
    End Sub

    Private _ucTruck As New ucTruck
    Private Sub buttonItemTruck_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonItemTruck.Click
        ButtonItem_Click(_ucTruck, New ucTruck)
    End Sub

    Private _ucCurrency As New ucCurrencies
    Private Sub ButtonItemCurrency_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonItemCurrency.Click
        ButtonItem_Click(_ucCurrency, New ucCurrencies)
    End Sub

    Private _ucGood As New ucGoods
    Private Sub ButtonItemGoodType_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonItemGoodType.Click
        ButtonItem_Click(_ucGood, New ucGoods)
    End Sub

    Private _ucAgent As New ucAgent
    Private Sub buttonItemAgent_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonItemAgent.Click
        ButtonItem_Click(_ucAgent, New ucAgent)
    End Sub

    Private _ucFee As New ucFee
    Private Sub ButtonItemCharge_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonItemCharge.Click
        ButtonItem_Click(_ucFee, New ucFee)
    End Sub

    Private _ucAccessory As ucAccessory
    Private Sub ButtonItemAccessory_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonItemAccessory.Click
        ButtonItem_Click(_ucAccessory, New ucAccessory(1))
    End Sub

    Private _ucUnit As ucUnit
    Private Sub ButtonItemUnit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonItemUnit.Click
        ButtonItem_Click(_ucUnit, New ucUnit)
    End Sub

    Private _ucPort As ucPort
    Private Sub ButtonItemPort_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonItemPort.Click
        ButtonItem_Click(_ucPort, New ucPort)
    End Sub

    Private _ucCountry As ucCountries
    Private Sub ButtonItemCountry_Click(sender As System.Object, e As System.EventArgs) Handles ButtonItemCountry.Click
        ButtonItem_Click(_ucCountry, New ucCountries)
    End Sub

    Private _ucLine As ucLine
    Private Sub ButtonItemLine_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonItemLine.Click
        ButtonItem_Click(_ucLine, New ucLine)
    End Sub

    Private _ucVessel As ucVessel
    Private Sub ButtonItemVessel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonItemVessel.Click
        ButtonItem_Click(_ucVessel, New ucVessel)
    End Sub

    Private _ucContofTNC As ucContTNC
    Private Sub btnContOfTNC_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnContOfTNC.Click
        ButtonItem_Click(_ucContofTNC, New ucContTNC)
    End Sub

    Private _ucAccessoryOfCont As ucAccessory
    Private Sub btnAccessoryOfCont_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAccessoryOfCont.Click
        ButtonItem_Click(_ucAccessoryOfCont, New ucAccessory(2))
    End Sub
End Class
